<?php

class Control_videocategory extends QUI_Control_Abstract
{
    function render()
    {
       
        $id = $this->id();
        $value = $this->get('value', '');
        $label = $this->get('label');
        $parentname = $this->_attrs['parentname'];
        $url = url('admin::educategory/getclasslist');
        $out = <<<EOT
        	
        	<div class="vocation"><div class="uew-select">
        		
        		<select id="$id" name="$id" class="select3" qform_group_id="" placeholder="二级分类" style="width: 102px;">
					<option value="0">请选择</option>
				</select>
			</div>

        <script type="text/javascript">

        	$("#$parentname").change(function(){
        		// $("#$id").find("option").remove(); 
        		// $("#$id").append('<option value="0">请选择</option>'); 
        		var pid = $(this).children('option:selected').val();
        		$.ajax({
        			url:"$url/id/"+pid,
        			success:function(result){
        				if(result){
        					result = $.parseJSON(result);
	        				$.each(result,function(k,v) {
	        					$("#$id").append("<option value="+k+">"+v+"</option>");

							});
        				}
        				


			    	}
			    });
			})

        </script>
EOT;

        return $out;
    }
}
